//
//  CLBinaryTree.h
//  Charles
//
//  Created by Leo on 2019/6/25.
//  Copyright © 2019 charles. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN


/**
 二叉树节点类
 */
@interface TreeNode : NSObject

@property (nonatomic, strong) TreeNode *leftLeaf;// 左叶子
@property (nonatomic, strong) TreeNode *rightLeaf;// 右叶子
@property (nonatomic, strong) NSString *nodeName;// 节点名称

@end

/**
 二叉树构造以及遍历类
 */
@interface CLBinaryTree : NSObject

// 构造一棵二叉树
- (TreeNode *)makeBinaryTree;

// 先序遍历
- (void)preorderTraversal:(TreeNode *)tree;

// 中序遍历
- (void)inorderTraversal:(TreeNode *)tree;

// 后序遍历
- (void)postorderTraversal:(TreeNode *)tree;

// 层次遍历
- (void)levelTraversal:(TreeNode *)tree;

// 二叉树深度
- (NSInteger)depthTree:(TreeNode *)tree;

// 翻转二叉树
- (TreeNode *)invertBinaryTree:(TreeNode *)tree;

@end


NS_ASSUME_NONNULL_END
